import axios from "axios";
import { userStore } from "@/store/user";

const service = axios.create({
    baseURL: "http://localhost:8088/bookmall",
    timeout: 60000,
    withCredentials: false,
    headers: {
        "Content-Type": "application/json",
        "X-Requested-With": "XMLHttpRequest",
        "Access-Control-Allow-Headers": "*",
    },
});

service.interceptors.request.use((config) => {
    config.headers["token"] = sessionStorage.getItem("token") === null ? "" : sessionStorage.getItem("token");
    return config;
});

service.interceptors.response.use((res) => {
    return res;
});

export default service;
